<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="btnAdd">添加属性</button>

    <script>
      function MyObject() {
        this.name = "name";
        this.age = 18;
      }

      var obj = new MyObject();

      document.getElementById("btnAdd").addEventListener("click", () => {
        obj.sex = "不男不女";
      });
    </script>
  </body>
</html>
